<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../css/mui.min.css" />
		<link rel="stylesheet" type="text/css" href="../css/common.css" />
		<style>
			.mui-content {
				text-align: center;
			}
			
			.mui-content .authing-status {
				display: none;
				width: 80%;
				margin: 40% 10%;
			}
			
			.mui-content .authing-status button {
				margin: 20% auto;
			}
			
			#yes_auth p.info {
				margin: 10px;
			}
			
			#yes_auth p.info label,
			#yes_auth p.info span {
				color: #333333;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-back mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">认证信息</h1>
		</header>
		<div class="mui-content">
			<!--未认证提示认证-->
			<div id="no_auth" class="authing-status">
				<p>您还未进行实名认证</p>
				<button class="mui-btn btn-main btn-block">我要认证</button>
			</div>
			<!--认证中-->
			<div id="authing" class="authing-status">
				<p>您已提交认证信息，正在审核中，请耐心等待</p>
			</div>
			<!--已认证显示认证信息-->
			<div id="yes_auth" class="authing-status">
				<p>认证通过</p>
				<p class="info"><label>真实姓名：</label><span id="authName"></span></p>
				<p class="info"><label>身份证号：</label><span id="idNum"></span></p>
			</div>
			<!--未通过认证-->
			<div id="noallow_auth" class="authing-status">
				<p>实名认证审核未通过，请重新认证</p>
				<button class="mui-btn btn-main btn-block">重新认证</button>
			</div>
		</div>
		<script src="../js/mui.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/common.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/user.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			var $status = $(".authing-status");
			mui.plusReady(function() {
				getData();
				function getData() {
					var url = baseURL + 'authState/get.json';
					Common.ajax({
						url : url
					}, function(data) {
						console.log(JSON.stringify(data));
						switch (data.code){
							case '-3': // 用户尚未提交认证文件
								$status.hide().filter('#no_auth').show();
								break;
							case '-2': // 实名认证审核未通过
								$status.hide().filter('#noallow_auth').show();
								break;
							case '-1': // 未登录
								$status.hide();
								mui.toast('获取帮办者验证信息失败，请重试');
								break;
							case '0': // 实名认证进行中
								$status.hide().filter('#authing').show();
								break;
							case '1':
								$status.hide().filter('#yes_auth').show();
								$("#authName").text(data.AuthState.authName);
								$("#idNum").text(data.AuthState.idNum);
								break;
							default:
								break;
						}
					}, function(xhr) {
						mui.toast('网络异常，请稍后再试');
						console.error('failed - ' + xhr.status + ' : ' + xhr.statusText);
					})
				}
				
				mui(".authing-status").on('tap', 'button', function() {
					Common.openWindow('artist-auth.html');
				})
				
				document.addEventListener('reload', function() {
					getData();
				})
			})
		</script>
	</body>

</html>